package com.monise.dao.DAO;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import com.monise.dao.BaseDao.GenericDao;
import com.monise.model.Animal;


public class AnimalDAO extends GenericDao<Animal> {

	public Animal getAnimal(Long codigo){
		EntityManager manager = getEntityManager();

		manager.getTransaction().begin();
        Query query = manager.createQuery("SELECT a from Animal a where a.pkAnimal=:codigo");
		query.setParameter("codigo",codigo);

		Animal animal = (Animal) query.getSingleResult();

		manager.getTransaction().commit();
		manager.close();

		return animal;
	}

}
